package com.example.project.controller;

import com.example.project.entity.User;
import com.example.project.vo.model.PageDto;
import com.example.project.aop.ResponseResult;
import com.example.project.entity.Project;
import com.example.project.service.ProjectService;
import com.example.project.vo.model.ProUserVo;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import io.swagger.annotations.ApiOperation;

import java.util.List;

/**
 * (Project)表控制层
 */
@Api(tags = "Project模块")
@ResponseResult
@RequestMapping("project")
public class ProjectController {

    public static final String modelName = "Project";
    /**
     * 服务对象
     */
    @Resource
    private ProjectService projectService;

    @ApiOperation("分页查询查询 " + modelName)
    @PostMapping("/page")
    public PageInfo<Project> queryAll(@RequestBody PageDto pageDto) {
        return this.projectService.queryAll(pageDto);
    }

    @ApiOperation(modelName + " list查询")
    @GetMapping("/list")
    public List<Project> querryList() {
        return this.projectService.querryList();
    }

    @ApiOperation("通过主键查询单条 " + modelName + " 数据")
    @GetMapping("/detail")
    public Project queryById(@RequestParam("id") Long id) {
        return this.projectService.queryById(id);
    }

    @ApiOperation("新增 " + modelName + " 数据")
    @PostMapping("/save")
    public Project add(@RequestBody Project project) {
        return this.projectService.insert(project);
    }

    @ApiOperation("编辑 " + modelName + " 数据")
    @PostMapping("/updateById")
    public Project edit(@RequestBody Project project) {
        return this.projectService.update(project);
    }

    @ApiOperation("通过id 删除 " + modelName + " 数据")
    @DeleteMapping("/delete")
    public Boolean deleteById(@RequestParam("id") Long id) {
        return this.projectService.deleteById(id);
    }


    @ApiOperation("项目状态修改")
    @GetMapping("/updateStatus")
    public void updateStatus(Long id,Integer status){
        projectService.updateStatus(id,status);
    }

    @ApiOperation("项目审核")
    @GetMapping("/updateApplyStatus")
    public void review(Long id,Integer applyStatus){
        projectService.review(id,applyStatus);
    }

}

